"""
水仙花数
"""
n = eval(input())
for i in range(10**(n-1), 10**n):
    sum1 = 0
    num = i
    while num != 0:
        num2 = num % 10
        sum1 += num2 ** n
        num //= 10
        if sum1 > i: break
    if sum1 == i:
        print(i)